//
//  RegistViewController.m
//  Xmpp
//
//  Created by lanou3g on 16/1/29.
//  Copyright © 2016年 徐强. All rights reserved.
//

#import "RegistViewController.h"
#import "Manager.h"
@interface RegistViewController ()
@property (weak, nonatomic) IBOutlet UITextField *userName;
@property (weak, nonatomic) IBOutlet UITextField *passWord;


@end

@implementation RegistViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
#pragma mark - 注册
#warning  未成功
- (IBAction)registButton:(id)sender {
    
    if (!self.userName.text && !self.passWord.text) {
        
    Manager *mgr = [Manager shareManage];
    //注册
    [mgr registWithUser:@"XQ" passWord:@"xq" success:^(id data) {
        //成功
        NSLog(@"注册成功");
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"注册成功" preferredStyle:(UIAlertControllerStyleAlert)];
        [self presentViewController:alert animated:YES completion:^{
            sleep(2);
            [alert dismissViewControllerAnimated:YES completion:nil];
        }];
        [self dismissViewControllerAnimated:YES completion:nil];
        
    } fail:^(NSError *err) {
        //失败
        NSLog(@"注册失败");
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"注册失败" preferredStyle:(UIAlertControllerStyleAlert)];
        [self presentViewController:alert animated:YES completion:^{
            sleep(2);
            [alert dismissViewControllerAnimated:YES completion:nil];
        }];

    }];
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
